import * as dd from "dingtalk-jsapi"
export function GetCode(callback) {
	return new Promise((resolve, reject) => {
		if (dd.env.platform !== "notInDingTalk") { //如果当前打开的浏览环境是钉钉
			dd.runtime.permission.requestAuthCode({
				corpId: "ding2ba49303e66b87de24f2f5cc6abecb85",
				onSuccess: function(result) {
					if (result.code) {
						resolve(result.code)
						//获取用户信息存session
					}
				},
				onFail: function(err) {
					alert(JSON.stringify(err));
				}

			})

		}
	})
}

export function isDD() {
	if (dd.env.platform !== "notInDingTalk") { //如果当前打开的浏览环境是钉钉
		return true
	} else {
		return false
	}
}